package com.wyl.salary.utils

import java.text.SimpleDateFormat
import java.util.*

private val formatter = SimpleDateFormat("yyyy-MM-dd")

/**
 * 时间格式化
 *
 * @receiver Date
 * @param pattern String yyyy-MM-dd
 * @return String
 */
fun Date.format(pattern: String = "yyyy-MM-dd"): String {
    formatter.applyPattern(pattern)
    return formatter.format(this)
}

/**
 *
 * @receiver String
 * @return Date
 */
fun String.toDate(pattern: String = "yyyy-MM-dd"): Date {
    formatter.applyPattern(pattern)
    return formatter.parse(this)
}
